/* Tables12S3.do
 Produce Tu and Hill Tables 1, 2, and S3.
*/

* Import and prepare data
import delimited "all_reviews_cleaned.csv", clear

global CLUSTERCODE "vce(cluster firm_id)"
summ

* Date variables.
qui gen date = date(date2, "YMD")
format date %td
qui gen year = year(date)
* Log n_reviews.
qui g log_reviews = log(firm_n_reviews)
label var log_reviews "Total reviews of firm (log)"

* Label variables.
label var bureau_title "Bureaucracy mentioned in headline"
label var bureau_cons "Bureaucracy mentioned in list of cons"
label var comp_benefits "Numeric rating of compensation and benefits"
label var firm_comp_benefits "Company average rating compensation and benefits"
label var lowpay_title  "Low pay mentioned in headline"
label var longhours_title "Long hours mentioned in headline"
label var conflict_title "Conflict mentioned in headline"
label var stress_title "Stress mentioned in headline"
label var forward_avg_title "Forward average bureaucracy mentioned in firm reviews"
label var forward_avg_con "Forward average bureaucracy mentioned in firm cons"

*****************
* Table 1. Basic regressions with bureau_title as predictor
*****************
estimates clear
eststo: regress overall bureau_title, $CLUSTERCODE
eststo: regress overall bureau_title comp_benefits, $CLUSTERCODE
eststo: regress overall bureau_title lowpay_title longhours_title conflict_title stress_title, $CLUSTERCODE

* Fixed effects regressions using reghdfe
eststo: reghdfe overall bureau_title comp_benefits, absorb(firm_id year) $CLUSTERCODE
eststo: reghdfe overall bureau_title lowpay_title longhours_title conflict_title stress_title, absorb(firm_id year) $CLUSTERCODE

esttab , se r2 ar2 label mtitles("" "" "" "Company + Year FE" "Company + Year FE")
esttab using "Table_1.tex", ///
  tex fragment replace label ///
  b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
  stats(N r2 r2_a F, fmt(%12,0gc 3 3 2) ///
      labels("Observations" "R-squared" "Adjusted R-squared" "F-statistic")) ///
  mtitles("" "" "" "Company + Year FE" "Company + Year FE") ///
  title("Bureaucracy Mentions and Overall Rating of Employer") ///
  nonotes addnotes("Robust standard errors clustered on firm in parentheses" "* p<0.10, ** p<0.05, *** p<0.01") ///
  alignment(D{.}{.}{-1}) width(\hsize)


*****************
* Table 2. IV regressions.
*****************
estimates clear
* First stage for bureau_title
eststo: regress bureau_title forward_avg_title comp_benefits log_reviews, $CLUSTERCODE
* IV regression for overall
eststo: ivregress 2sls overall comp_benefits log_reviews (bureau_title = forward_avg_title), first $CLUSTERCODE

* Table.
esttab , se r2 ar2 label mtitles("First Stage" "IV") depvars
esttab using "Table_2.tex", ///
  tex fragment replace label order(bureau_title) ///
  b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
  stats(N r2 r2_a F, fmt(%12,0gc 3 3 2) ///
      labels("Observations" "R-squared" "Adjusted R-squared" "F-statistic")) ///
  mtitles("First Stage" "IV: Rating") ///
  title("Instrumental Variable Results: Bureaucracy Mentions and Overall Rating of Employer") ///
  nonotes addnotes("Robust standard errors clustered on firm in parentheses" "* p<0.10, ** p<0.05, *** p<0.01") ///
  alignment(D{.}{.}{-1}) width(\hsize)

  
*****************
* Table S3. Basic regressions by five year period.
*****************
estimates clear
* 2008 to 2012
eststo: reghdfe overall bureau_title comp_benefits if year < 2013, absorb(firm_id year) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedfirm "Yes", replace
	qui summ overall if e(sample)
  qui estadd local ymean = r(mean), replace
eststo: reghdfe overall bureau_title lowpay_title longhours_title conflict_title stress_title if year < 2013, absorb(firm_id year) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedfirm "Yes", replace
	qui summ overall if e(sample)
  qui estadd local ymean = r(mean), replace

* 2013 to 2018
eststo: reghdfe overall bureau_title comp_benefits if 2013 <= year & year < 2019, absorb(firm_id year) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedfirm "Yes", replace
	qui summ overall if e(sample)
  qui estadd local ymean = r(mean), replace
eststo: reghdfe overall bureau_title lowpay_title longhours_title conflict_title stress_title if 2013 <= year & year < 2019, absorb(firm_id year) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedfirm "Yes", replace
	qui summ overall if e(sample)
  qui estadd local ymean = r(mean), replace

* 2019 to 2024
eststo: reghdfe overall bureau_title comp_benefits if 2020 <= year, absorb(firm_id year) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedfirm "Yes", replace
	qui summ overall if e(sample)
  qui estadd local ymean = r(mean), replace
eststo: reghdfe overall bureau_title lowpay_title longhours_title conflict_title stress_title if 2019 <= year, absorb(firm_id year) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedfirm "Yes", replace
	qui summ overall if e(sample)
  qui estadd local ymean = r(mean), replace

esttab , se r2 ar2 label mgroups("2008 to 2012" "2013 to 2018" "2019 to 2023", pattern(1 0 1 0 1 0) span)
esttab using "Table_S3.tex", ///
  tex fragment replace label ///
  b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
  nodepvar ///
  stats(N r2 r2_a F ymean fixedfirm fixedyear, fmt(%12,0gc 3 3 2 2 %3s %3s) ///
      labels("Observations" "R-squared" "Adjusted R-squared" "F-statistic" "Mean of Outcome" "Company FEs" "Year FEs")) ///
	mtitles("2008 to 2012" "2008 to 2012" "2013 to 2018" "2013 to 2018" "2019 to 2024" "2019 to 2024") ///
  title("Bureaucracy Mentions and Overall Rating of Employer") ///
  nonotes addnotes("Robust standard errors clustered on firm in parentheses" "* p<0.10, ** p<0.05, *** p<0.01") ///
  alignment(D{.}{.}{-1}) width(\hsize)

